package com.qf.advice;/*
 *徐韬
 *2021/10/18
 *15:10
 */

import org.aspectj.lang.ProceedingJoinPoint;

public class Myadvice {
    public void writeLog(){//前置增强
        System.out.println("增强日志");
    }
    public void afterReturning(Object result){//后置增强
        System.out.println("后置增强实现，接收到的结果为："+result);
    }
    public void around(ProceedingJoinPoint proceedingJoinPoint)throws Throwable{//环绕增强
        try {
            System.out.println("环绕增强，事务开启");
            Object pro = proceedingJoinPoint.proceed();
            System.out.println("事务提交");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("事务回滚");
        }
    }
    public void afterThrowing(Exception e){//异常增强
        System.out.println("异常增强："+e.getMessage());
    }
    public void after(){//最终增强
        System.out.println("最终增强");
    }
}
